<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    li{
      width: 400px;
      height: 50px;
      background-color: #e1e7d3;
      margin-top: 20px;
    }
  </style>
</head>
<body>
  <div id="app">
    <input type="text" v-model="msg">
    {{msg}}
    <hr>
    <button @click="arr.push(arr.length+1)">新增数组</button>
    {{arr}}
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const  app = createApp({
      data(){
        return {
          msg: 'hello',
          arr: [1,2,3,4]
        }
      },
      watch: {
        // 侦听基础数据类型  基础侦听器侦听原理 直接侦听值得变化 改变触发 不改变不触发
        msg(newVal, oldVal){
          console.log('msg改变了新值', newVal, '旧值', oldVal);
        },
        // 引用类型侦听
        arr(val) {
          console.log('arr改变了');
        }
      }
    })

    app.mount('#app')
  </script>
</body>
</html>